package com.lhj.myapplication.controller;

import com.lhj.myapplication.common.RestDataResult;
import com.lhj.myapplication.common.RestResultCode;
import com.lhj.myapplication.service.ArticleTypeService;
import com.lhj.myapplication.vo.ArticleTypeViewModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ArticleTypeController {
    @Autowired
    private ArticleTypeService articleTypeService;
    @GetMapping("/article/types")
    @ApiOperation("获取博客类别")
    public RestDataResult getAll(){
        RestDataResult<List<ArticleTypeViewModel>> restDataResult=new RestDataResult<>();
        List<ArticleTypeViewModel> types = articleTypeService.getAll();
        restDataResult.setData(types);
        restDataResult.setCode(RestResultCode.SUCCESS.code());
        restDataResult.setMsg("success");
        return restDataResult ;
    }
}
